<table class="table table-hover">
    <tr>
        <th>ID</th>
        <th>真实名称</th>
        <th>电话号码</th>
        <th>身份证号码</th>
        <th>支付宝帐号</th>
        <th>分销提成比例</th>
        <th>状态</th>
        <th>申请时间</th>
        <th>操作</th>
    </tr>
    <?php if($data):?>
    <?php foreach($data as $k => $v):?>
    <tr>
        <td><?php echo $v['id']?></td>
        <td><?php echo $v['name']?></td>
        <td><?php echo $v['mobile']?></td>
        <td><?php echo $v['id_card']?></td>
        <td><?php echo $v['alipay_account']?></td>
        <td><?php echo $v['commission_rate']?>%</td>
        <td>

            <?php

                $_status = [

                    1 => '<span class="orange">申请中</span>',
                    2 => '<span class="green">申请通过</span>',
                    3 => '<span class="red">申请被拒绝</span>',

                ];

                echo $_status[$v['status']];
            ?>




        </td>
        <td><?php echo date('Y-m-d H:i:s',$v['create_time'])?></td>
        <td data-id="<?php echo $v['id']?>" data-mobile="<?php echo $v['mobile']?>" data-uid="<?php echo $v['uid']?>">

            <?php if($v['status'] == 1):?>

            <a href="javascript:;" class="btn btn-xs btn-danger refuse">拒绝</a>
            <a href="javascript:;" class="btn btn-xs btn-success agree">同意</a>
            <?php endif;?>

        </td>
    </tr>
    <?php endforeach;?>
    <?php else:?>
    <tr>
        <td colspan="7" style="text-align:center;tong-size: 30px; font-weight: bold">
            没有找到符合条件的数据!
        </td>
    </tr>
    <?php endif;?>
</table>
<div role="group" data-total="<?php echo $total?>" data-page="<?php echo $page?>" data-nums="<?php echo $nums?>" data-src="<?php echo U('Admin/Member/Distribution/lists');?>"  class="btn-group" id="_pages"></div>
<script>
    $(function(){

        var options = {

            status: '<?php echo $status?>'

        }

        Admin.pages(options);

        $('.refuse').unbind('click');
        $('.refuse').click(function(){

            var _this   =   $(this);
            var data    =   {};
            data.id     =   _this.parent().data('id');
            data.uid    =   _this.parent().data('uid');
            data.mobile    =   _this.parent().data('mobile');

            layer.prompt({title: '请输入拒绝理由!', formType: 2},function(val){

            data.message = val;

            layer.load();
            $.ajax({

                url     : '<?php echo U("Admin/Member/Distribution/refuse")?>',
                type    : 'post',
                data    : {data:data}

            })
                    .done(function(result){

                        layer.closeAll();
                        if(result.code == 200){

                            var datas = options;
                            datas.page = '<?php echo $page?>';
                            showMessage(result.msg,result.code,'<?php echo U("Admin/Member/Distribution/lists")?>',datas,200);

                        } else {

                            showMessage(result.msg,result.code,'','',2000);

                        }

                    });

            });

        });

        $('.agree').click(function(){

            var _this   =   $(this);
            var data    =   {};
            data.id     =   _this.parent().data('id');
            data.uid    =   _this.parent().data('uid');
            data.mobile    =   _this.parent().data('mobile');


            layer.prompt({
                formType: 0,
                value: 0,
                title: '分销比例为0-100%,单位%'
            }, function(value, index, elem){
                data.commission_rate    =   Number(value);
                if(data.commission_rate < 0 || data.commission_rate > 100){
                    layer.msg('请输入正确的分销比例!',{shift:6});
                    return false;
                }
                layer.load();
                $.ajax({
                    url     : '<?php echo U("Admin/Member/Distribution/agree")?>',
                    type    : 'post',
                    data    : {data:data}
                }).done(function(result){
                    layer.closeAll();
                    if(result.code == 200){
                        var datas = options;
                        datas.page = '<?php echo $page?>';
                        showMessage(result.msg,result.code,'<?php echo U("Admin/Member/Distribution/lists")?>',datas,200);
                    } else {
                        showMessage(result.msg,result.code,'','',2000);
                    }
                });
            });

        });


    });
</script>